<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>十二小时时钟</title>
	<style type="text/css">
		div{
			width: 200px;
			height: 200px;
			border: 1px solid lightblue;
			margin: 50px auto;
			line-height: 200px;
			border-radius: 100px;
			background-color: pink;
		}
	</style>
	<script type="text/javascript">
		window.onload=function(){
			setInterval(function(){
			var date=new Date();
			var hour=getMorning(date.getHours());
			var minute= getZero(date.getMinutes());
			var second= getZero(date.getSeconds());
			var str=hour+'时'+minute+'分'+second+'秒';
			document.getElementById('time').innerHTML=str;},1000)
			function getZero(num){
				return num>=10?num+'':'0'+num;
			}
			function getMorning(num){
				return num>=13?num>=22?'下午：'+(num-12):'下午：'+'0'+(num-12):num>=10?'上午：'+num:'上午：'+'0'+num;
			}
		}
	</script>
</head>
<body>
	<div id="time" align="center"></div>
</body>
</html>